import axios from 'axios';
axios.interceptors.request.use(config=>{
    const token  = localStorage.getItem('token');
    const headers = {}
    if(token) {
        headers.authorization = token;
    }
    return {
        ...config,
        headers
    }
})
axios.interceptors.response.use(response=>{
    return response.data;
},err=> {
    switch(err.response.status) {
        case 401: 
        console.log("重定向到登录页")
        break;
    }
    return Promise.reject(err)
})


export default axios;